package com.xiangban.feign.fallback;

import com.xiangban.feign.UserServiceFeign;
import com.xiangban.model.TUser;
import com.xiangban.model.res.ApiResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;

/**
 * @Author ly
 * @date 2021/11/30 17:29
 */

@Component
@Slf4j
public class UserServiceFallback implements FallbackFactory<UserServiceFeign> {

    public UserServiceFeign create(Throwable throwable) {
        return new UserServiceFeign() {

            @Override
            public ApiResult<Object> getUserInfo(String token) {
                return ApiResult.newError("personnel =>>> getUserInfo 服务接口异常");
            }

            @Override
            public ApiResult<Object> updateUserInfo(HashMap<String, Object> map) {
                log.info("personnel =>>> getUserInfo 服务接口异常");
                return ApiResult.newError("personnel =>>> getUserInfo 服务接口异常");
            }

            @Override
            public ApiResult<List<TUser>> getUserList() {
                log.info("personnel =>>> getUserInfo 服务接口异常");
                return ApiResult.newError("personnel =>>> getUserInfo 服务接口异常");
            }


        };
    }
}
